package ctr;

import java.util.ArrayList;

import db.DbConnection;
import db.DbGuest;
import model.Guest;


public class Gctr {
	
	public ArrayList<Guest> findAllGuests()
    {
      DbGuest dbg = new DbGuest();
      ArrayList<Guest> allp = dbg.getAll(false);
      return allp;
    }
	
	
	public void insertNew(String fname, String lname, String address, String country, String phone, String email, String travelAgency)
    {    
         Guest oObj = new Guest();
         oObj.setFname(fname);
         oObj.setLname(lname);
         oObj.setAddress(address);
         oObj.setCountry(country);
         oObj.setPhone(phone);
         oObj.setEmail(email);
         oObj.setTravelAgency(travelAgency);
         
  
         try{
          DbConnection.startTransaction();
          DbGuest dbg = new DbGuest();
          dbg.insert(oObj);
          DbConnection.commitTransaction();
         }
         catch(Exception e)
         {
             DbConnection.rollbackTransaction();
         }
    }

}
